package com.ruoyi.classai.service.impl;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.ruoyi.classai.domain.dto.HomeworkDto;
import org.springframework.stereotype.Service;
import com.ruoyi.classai.mapper.EwcHomeworkSubmissionMapper;
import com.ruoyi.classai.domain.EwcHomeworkSubmission;
import com.ruoyi.classai.service.IEwcHomeworkSubmissionService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import java.util.Date;

/**
 * 课后作业提交Service业务层处理
 * 
 * @author lcj
 * @date 2025-02-28
 */
@Service
public class EwcHomeworkSubmissionServiceImpl extends ServiceImpl<EwcHomeworkSubmissionMapper, EwcHomeworkSubmission> implements IEwcHomeworkSubmissionService {


    @Override
    public boolean correctHomeWork(HomeworkDto homeworkDto) {
        QueryWrapper<EwcHomeworkSubmission> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("homework_submission_id",homeworkDto.getHomeworkSubmissionId());
        queryWrapper.eq("homework_id",homeworkDto.getHomeworkId());
        queryWrapper.eq("student_id", homeworkDto.getStudentId());
        ewcHomeworkSubmission.setCorrectStatus("1");
        Date currentDate = new Date();
        ewcHomeworkSubmission.setCorrectDate(currentDate);
        ewcHomeworkSubmission.setTeacherFeedback(homeworkDto.getTeacherFeedback());
        return this.update(ewcHomeworkSubmission, queryWrapper);
    }
}
